package com.mes.biz.domain.vo;

import com.mes.biz.domain.BizProduct;
import com.mes.common.utils.StringUtils;

import java.math.BigDecimal;

/**
 * @author wy
 * @title: ConvertRatioNumber
 * @projectName mes
 * @description:
 * @date 2023-11-03 16:12
 */
public class ConvertRatioNumberUnit {

    public static BigDecimal convertRatio(BigDecimal number, String unit, BizProduct bizProduct) {
        BigDecimal basicNumber=BigDecimal.ZERO;
        if (StringUtils.isNotEmpty(unit)){
            switch (unit){
                case "1":
                    basicNumber=number;
                    break;
                case "2":
                    basicNumber=number.multiply(bizProduct.getConvertRatioA());
                    break;
                case "3":
                    basicNumber=number.multiply(bizProduct.getConvertRatioB());
                    break;
            }
        }else {
            basicNumber=number;
        }
        return basicNumber;
    }
}
